package com.comum.javahomework420242025.repository;

import com.comum.javahomework420242025.pojo.Chance;
import com.comum.javahomework420242025.pojo.WeeklyReport;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ChanceRepository extends JpaRepository<Chance, Long> {


    // 模糊匹配id、name和score字段
    @Query("SELECT c FROM Chance c WHERE " +
            "LOWER(c.phase) LIKE %:state% OR " +
            "LOWER(c.projectname) LIKE %:state% OR " +
            "LOWER(c.budget) LIKE %:state% OR " +
            "LOWER(c.stock) LIKE %:state%")
    Page<Chance> list(@Param("state") String state, Pageable pageable);

    @Query("SELECT c FROM Chance c WHERE " +
            "c.clientcompanyid = :str AND (c.projectname LIKE %:findType% OR c.phase LIKE %:findType%)")
    List<Chance> getAllChanceByClientId(String str, String findType);
}